import 'package:banyou_app/app/config/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class LoginButton extends StatelessWidget {
  final String title;
  final bool enable;
  final VoidCallback? onPressed;
  final Color? color;

  const LoginButton(this.title,
      {this.enable = true, this.onPressed, this.color = ColorConfig.app_main});

  @override
  Widget build(BuildContext context) {
    return FractionallySizedBox(
      widthFactor: 1,
      child: MaterialButton(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
        height: 46,
        padding: EdgeInsets.zero,
        splashColor: ColorConfig.app_main,
        hoverColor: ColorConfig.app_main,
        elevation: 0,
        onPressed: enable ? onPressed : null,
        disabledColor: (color ?? ColorConfig.app_main).withAlpha(50),
        color: color ?? ColorConfig.app_main,
        child: Text(
          title,
          style: TextStyle(
              color: color == ColorConfig.app_main
                  ? Colors.white
                  : ColorConfig.text_label,
              fontSize: title == '开启' ? 14.sp : 18.sp),
        ),
      ),
    );
  }
}
